package com.example.myapplication;

import androidx.appcompat.app.AppCompatActivity;
import androidx.constraintlayout.widget.ConstraintLayout;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;

import org.w3c.dom.Text;

public class MainActivity extends AppCompatActivity {

    private String text = "";    // 计算表达式
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.calculator);

        TextView textView = findViewById(R.id.text_view);
        Button button = findViewById(R.id.eight);
        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                // 处理事件的代码   在界面上显示8
                text += "8";
                textView.setText(text);
            }
        });

        Button button2 = findViewById(R.id.nine);
        button2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                // 处理事件的代码   在界面上显示8
                text += "9";
                textView.setText(text);
            }
        });

        Calculator calculator = new Calculator();
        Double a = calculator.Eval("1+2-3");
    }
}